package beans;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import org.apache.myfaces.custom.fileupload.UploadedFile;
import org.apache.tomcat.dbcp.dbcp.BasicDataSource;

public class Offer {
	
	public static class Subcategory
	{
		private int primarykey;
		private String subcatName;
		private boolean event;
		
		public Subcategory(int primarykey, String subcatName, boolean event) {
			this.primarykey = primarykey;
			this.subcatName = subcatName;
			this.event = event;
		}
		
		
		public Subcategory() {
		}


		public int getPrimarykey() {
			return primarykey;
		}
		public void setPrimarykey(int primarykey) {
			this.primarykey = primarykey;
		}
		public String getSubcatName() {
			return subcatName;
		}
		public void setSubcatName(String subcatName) {
			this.subcatName = subcatName;
		}
		public boolean isEvent() {
			return event;
		}
		public void setEvent(boolean event) {
			this.event = event;
		}	
		
	}
	
	public static class ReservatedOffer
	{
		private String name, desc;

		public ReservatedOffer() {
		}

		public ReservatedOffer(String name, String desc) {
			this.name = name;
			this.desc = desc;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public String getDesc() {
			return desc;
		}

		public void setDesc(String desc) {
			this.desc = desc;
		}
		
		
	}

	
	private ArrayList<Subcategory> subcategories;
	private ArrayList<MyOfferDisplay> myOfferDisplay;
	private ArrayList<ReservatedOffer> resOffers;
	private String resType;
	private int selectedOfferId;
	
	BasicDataSource ds;
	UserBean uBean;
	private boolean renderQuestion;
	private boolean event;
	private boolean discount;
	private boolean valid;
	
	//page properties BASIC
	private String offerName;
	private String offerDescription;
	private UploadedFile picture;
	private Date endDate;
	private double initialPrice;
	private int initialAmount;
	private int selectedSubcategoryPK;
	// page properties EVENT
	private String eventPlace;
	private Date eventStartDate;
	private Time eventStartTime;
	private Time eventEndTime;
	//helper
	private String strEventStartTime;
	private String strEventEndTime;
	// page properties DISCOUNT
	private Date discountEndDate;
	private double discountPrice;
	
	//render buttons
	private boolean renderDiscount, renderEvent;
	
	//for editingOffer
	private int thisOfferId;
	private Date startDate;
	private int amountLeft;
	int doubleInitialAmount;

	public Offer(BasicDataSource ds, UserBean bean) {
		this.ds = ds;
		event = false;
		discount = false;
		uBean = bean;
		subcategories = new ArrayList<Offer.Subcategory>();
		loadPossibleSubcategories();
		renderDiscount = true;
		renderEvent = true;
	}
	
	public String offerIsEvent()
	{
		event = true;
		renderEvent = false;
		return null;
	}
	
	public String offerIsOnDiscount()
	{
		discount = true;
		renderDiscount = false;
		return null;
	}
	
	public void loadPossibleSubcategories()
	{
		Connection cnn = null;
		Statement stat = null;
		ResultSet rs = null;
		int firstActivity = uBean.getActivity1id();
		String getCorespondingCategory = "SELECT idOfferCat FROM catact WHERE (idCompanyAct = " + firstActivity;
		int secondActivity = uBean.getActivity2id();
		if(secondActivity != 0)
		{
			getCorespondingCategory += "OR idCompanyAct = " + secondActivity;
		}
		int thirdActivity = uBean.getActivity3id();
		if(thirdActivity != 0)
		{
			getCorespondingCategory += "OR idCompanyAct = " + thirdActivity;
		}
		
		getCorespondingCategory += ")";
		ArrayList<Integer> categoriesId = new ArrayList<Integer>();
		
		
		try {
			cnn = ds.getConnection();
			stat = cnn.createStatement();
			rs = stat.executeQuery(getCorespondingCategory);
			while(rs.next())
			{
				Integer currentId = rs.getInt("idOfferCat");
				categoriesId.add(currentId);
			}
			
			rs.close();
			stat.close();
			
			for(Integer i: categoriesId)
			{
				String getSubcategories = "SELECT * FROM offersubcategory WHERE idCategory = " + i;
				stat = cnn.createStatement();
				rs = stat.executeQuery(getSubcategories);
				while(rs.next())
				{
					int primKey = rs.getInt("idOfferSubcategory");
					String subName = rs.getString("subcategoryName");
					boolean ev = rs.getBoolean("isEvent");
					subcategories.add(new Subcategory(primKey, subName, ev));
				}
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
			if(rs != null)
			{
				try {
					rs.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		
		
	}
	
	public String publishOffer()
	{
		Connection cnn = null;
		PreparedStatement stat = null;
//		if(eventPlace != null)
//		{
//			event = true;
//		}
//		else
//		{
//			event = false;
//		}
//		
//		if(discountEndDate != null)
//		{
//			discount = true;
//		}
//		else
//		{
//			discount = false;
//		}
		
		try {
			cnn = ds.getConnection();
			String statementString = "INSERT INTO offers(title, isEvent, aboutOffer, offerStarts, offerEnds, idCompany, picture, price, initialAmount, amountLeft, hasDiscount, discountPrice, " +
					"offerSubcategory, eventPlace, eventStarts, eventStartTime, eventEndTime, discountEnds) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
			
			stat = cnn.prepareStatement(statementString);
			stat.setNString(1, offerName);
			stat.setBoolean(2, event);
			stat.setNString(3, offerDescription);
			
			Date today = new Date();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			String currentTime = sdf.format(today);
			stat.setString(4, currentTime);
			
			java.sql.Date offerEndsSql = new java.sql.Date(endDate.getTime());
			stat.setDate(5, offerEndsSql);
			
			int myId = uBean.getUserId();
			stat.setInt(6, myId);
			//load image
			InputStream is = picture.getInputStream();
			stat.setBinaryStream(7, is, picture.getSize());
			
			stat.setDouble(8, initialPrice);
			
			stat.setInt(9, initialAmount);
			stat.setInt(10, initialAmount);
			
			stat.setBoolean(11, discount);
			
			if(discount)
			{
				stat.setDouble(12, discountPrice);
				
				java.sql.Date discountEndsSql = new java.sql.Date(discountEndDate.getTime());
				stat.setDate(18, discountEndsSql);
			}
			else
			{
				stat.setNull(12, java.sql.Types.DOUBLE);
				stat.setNull(18, java.sql.Types.DATE);
			}
			
			stat.setInt(13, selectedSubcategoryPK);
			
			if(event)
			{
				stat.setNString(14, eventPlace);
				// set event starts date
				java.sql.Date eventStartsSql = new java.sql.Date(eventStartDate.getTime());
				stat.setDate(15, eventStartsSql);
				if(isValidTime(strEventStartTime))
				{
					stat.setString(16, strEventStartTime);
				}
				else
				{
					return null;
				}
				
				if(isValidTime(strEventEndTime))
				{
					stat.setString(17, strEventEndTime);
				}
				else
				{
					return null;
				}
			}
			else
			{
				stat.setNull(14, java.sql.Types.VARCHAR);
				stat.setNull(15, java.sql.Types.DATE);
				stat.setNull(16, java.sql.Types.VARCHAR);
				stat.setNull(17, java.sql.Types.VARCHAR);
			}
			
			stat.executeUpdate();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		
		return null;
	}

	
	private boolean isValidTime(String time)
	{
		String[] hrMin = time.split(":");
		if(hrMin.length != 2)
		{
			return false;
		}
		int hr, min;
		try
		{
			hr = Integer.parseInt(hrMin[0]);
			min = Integer.parseInt(hrMin[1]);
		}catch(Exception e)
		{
			return false;
		}
		
		if(hr < 0 || hr > 23)
		{
			return false;
		}
		
		if(min < 0 || min > 59)
		{
			return false;
		}
		
		return true;
	}
	
	public void loadMyOffers()
	{
		Connection cnn = null;
		Statement stat = null;
		ResultSet rs = null;
		myOfferDisplay = new ArrayList<MyOfferDisplay>();
		
		String query = "SELECT idOffers, title, aboutOffer, isEvent, price, hasDiscount, discountPrice, initialAmount, amountLeft, isValid, picture FROM offers WHERE idCompany = " + uBean.getUserId();
		
		try {
			cnn = ds.getConnection();
			stat = cnn.createStatement();
			rs = stat.executeQuery(query);
			while(rs.next())
			{
				MyOfferDisplay thisOffer = new MyOfferDisplay();
				int offerId = rs.getInt("idOffers");
				thisOffer.setOfferId(offerId);
				
				String title = rs.getString("title");
				thisOffer.setTitle(title);
				
				String desc = rs.getString("aboutOffer"); 
				thisOffer.setDescription(desc);
				
				boolean e = rs.getBoolean("isEvent");
				thisOffer.setEvent(e);
				
				double p = rs.getDouble("price");
				thisOffer.setPrice(p);
				
				boolean d = rs.getBoolean("hasDiscount");
				thisOffer.setHasDiscount(d);
				
				double dp = rs.getDouble("discountPrice");
				thisOffer.setDiscountPrice(dp);
				
				int initA = rs.getInt("initialAmount");
				thisOffer.setInitialAmount(initA);
				
				int amountL = rs.getInt("amountLeft");
				thisOffer.setAmountLeft(amountL);
				
				boolean iv = rs.getBoolean("isValid");
				thisOffer.setValid(iv);
				
				String str = rs.getString("picture");
				int len = str.length();
				byte[] img = new byte[len];
				InputStream imgStream = rs.getBinaryStream("picture");
//				try {
//					imgStream.read(img, 0, len);
//				} catch (IOException e1) {
//					// TODO Auto-generated catch block
//					e1.printStackTrace();
//				}
//				thisOffer.setIs(imgStream);
//				thisOffer.setImage(img);
				
				OutputStream outS = null;
				//String location = FacesContext.getCurrentInstance().getExternalContext().getRealPath("webapps/reservation-pia/resources");
	
				//File out = new File("C:\\" + offerId + ".jpg");
				File out = new File("E:\\Servers\\apache-tomcat-7.0.23\\webapps\\reservation-pia\\" + offerId + ".jpg");
				try {
					outS = new FileOutputStream(out);
				} catch (FileNotFoundException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				
				int i;
				while((i = imgStream.read(img)) > 0)
				{
					outS.write(img, 0, i);
				}
				
				outS.close();
				imgStream.close();
				
				if(amountL == 0)
				{
					thisOffer.setStatus("Распродато");
				}
				else
				{
					thisOffer.setStatus("Није распродато");
				}
				
				myOfferDisplay.add(thisOffer);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}
	
	public String removeSelectedOffer()
	{
		Connection cnn = null;
		Statement stat = null;
		
		try {
			cnn = ds.getConnection();
			stat  = cnn.createStatement();
			String updateValid = "UPDATE offers SET isValid = false WHERE idOffers = " + selectedOfferId;
			stat.executeUpdate(updateValid);
			loadMyOffers();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		return null;
	}
	
	public String updateSelectedOffer()
	{
		Offer o = new Offer(ds, uBean);
		uBean.setEditingOffer(o);
		o.setThisOfferId(selectedOfferId);
		createEditedOffer(o);
		return "editoffer";
	}
	
	public String updateOfferDb()
	{
		Connection cnn = null;
		PreparedStatement stat = null;
		
		try {
			cnn = ds.getConnection();
		
			String updateString = "UPDATE offers SET title = ?, isEvent = ?, aboutOffer = ?, offerStarts = ?, offerEnds = ?, price = ?, initialAmount = ?, amountLeft = ?, " +
					"hasDiscount = ?, discountPrice = ?, offerSubcategory = ?, eventPlace = ?,  eventStarts = ?, eventStartTime = ?, eventEndTime = ?, discountEnds " +
					"= ? WHERE idOffers = " + thisOfferId;
			
			stat = cnn.prepareStatement(updateString);
			stat.setNString(1, offerName);
			stat.setBoolean(2, event);
			stat.setNString(3, offerDescription);
			
			java.sql.Date startDateSql = new java.sql.Date(startDate.getTime());
			stat.setDate(4, startDateSql);
			
			java.sql.Date endDateSql = new java.sql.Date(endDate.getTime());
			stat.setDate(5, endDateSql);
			
			stat.setDouble(6, initialPrice);
			stat.setInt(7, initialAmount);
			
			int newLeft = (initialAmount - doubleInitialAmount) + amountLeft;
			stat.setInt(8, newLeft);
			
			stat.setBoolean(9, discount);
			if(discount)
			{
				stat.setDouble(10, discountPrice);
				if(discountEndDate != null)
				{
					java.sql.Date d = new java.sql.Date(discountEndDate.getTime());
					stat.setDate(16, d);
				}
				
				
			}
			else
			{
				stat.setNull(10, java.sql.Types.DOUBLE);
				stat.setNull(16, java.sql.Types.DATE);
			}
			
			stat.setInt(11, selectedSubcategoryPK);
			
			if(event)
			{
				stat.setNString(12, eventPlace);
				if(eventStartDate != null)
				{
					java.sql.Date ed = new java.sql.Date(eventStartDate.getTime());
					stat.setDate(13, ed);
				}
				
				if(isValidTime(strEventStartTime))
				{
					stat.setString(14, strEventStartTime);
				}
				
				if(isValidTime(strEventEndTime))
				{
					stat.setString(15, strEventEndTime);
				}
				
			}
			else
			{
				stat.setNull(12, java.sql.Types.VARCHAR);
				stat.setNull(13, java.sql.Types.DATE);
				stat.setNull(14, java.sql.Types.VARCHAR);
				stat.setNull(15, java.sql.Types.VARCHAR);
			}
			
			stat.executeUpdate();
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.out.println(stat);
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		
		uBean.setNewOffer(new Offer(ds, uBean));
		uBean.getNewOffer().loadMyOffers();
		
		return "myoffers";
	}
	
	void createEditedOffer(Offer forOffer)
	{
		
		int selectedOffer = forOffer.getThisOfferId();
		Connection cnn = null;
		Statement stat = null;
		ResultSet rs = null;
		
		try {
			cnn = ds.getConnection();
			stat = cnn.createStatement();
			String queryGetSelectedOffer = "SELECT * FROM offers WHERE idOffers = " + selectedOffer;
			rs = stat.executeQuery(queryGetSelectedOffer);
			rs.next();
			
			String title = rs.getString("title");
			forOffer.setOfferName(title);
			
			String desc = rs.getString("aboutOffer");
			forOffer.setOfferDescription(desc);
			
			java.sql.Date ed = rs.getDate("offerEnds");
			forOffer.setEndDate(new Date(ed.getTime()));
			
			java.sql.Date sd = rs.getDate("offerStarts");
			forOffer.setStartDate(new Date(sd.getTime()));
			
			double initP = rs.getDouble("price");
			forOffer.setInitialPrice(initP);
			
			boolean isEvent = rs.getBoolean("isEvent");
			forOffer.setEvent(isEvent);
			
			//id company
			
			int initAmount = rs.getInt("initialAmount");
			forOffer.doubleInitialAmount = initAmount;
			forOffer.setInitialAmount(initAmount);
			
			int amountLeft = rs.getInt("amountLeft");
			forOffer.setAmountLeft(amountLeft);
			
			boolean hasDiscount = rs.getBoolean("hasDiscount");
			forOffer.setDiscount(hasDiscount);
			
			double dicountPrice = rs.getDouble("discountPrice");
			forOffer.setDiscountPrice(dicountPrice);
			
			int offerSubcat = rs.getInt("offerSubcategory");
			forOffer.setSelectedSubcategoryPK(offerSubcat);
			
			String eventPlace = rs.getString("eventPlace");
			forOffer.setEventPlace(eventPlace);
			
			java.sql.Date es = rs.getDate("eventStarts");
			if(es != null)
			{
				forOffer.setEventStartDate(new Date(es.getTime()));
			}
			
			String st = rs.getString("eventStartTime");
			forOffer.setStrEventStartTime(st);
			
			String et = rs.getString("eventEndTime");
			forOffer.setStrEventEndTime(et);
			
			java.sql.Date discountE = rs.getDate("discountEnds");
			if(discountE != null)
			{
				forOffer.setDiscountEndDate(new Date(discountE.getTime()));
			}
			
			boolean validOffer = rs.getBoolean("isValid");
			forOffer.setValid(validOffer);
		
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}
	
	public void loadMyReservations(boolean isConfirmed)
	{
		Connection cnn = null;
		Statement stat = null;
		ResultSet rs = null;
		resOffers = new ArrayList<Offer.ReservatedOffer>();
		
		try {
			cnn = ds.getConnection();
			stat = cnn.createStatement();
			String selectReservationsString = "SELECT title, aboutOffer FROM  offers WHERE idOffers IN (SELECT idOffer FROM reservations WHERE idUser = " + uBean.getUserId() + 
					" AND isConfirmed = ";
			
			if(isConfirmed)
			{
				selectReservationsString += "true)";
			}
			else
			{
				selectReservationsString += "false)";
			}
			
			rs = stat.executeQuery(selectReservationsString);
			while(rs.next())
			{
				String about = rs.getString("aboutOffer");
				String name = rs.getString("title");
				resOffers.add(new ReservatedOffer(name, about));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally
		{
			if(cnn != null)
			{
				try {
					cnn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			if(stat != null)
			{
				try {
					stat.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
		
	}

	public boolean isRenderQuestion() {
		return renderQuestion;
	}


	public void setRenderQuestion(boolean renderQuestion) {
		this.renderQuestion = renderQuestion;
	}


	public boolean isEvent() {
		return event;
	}


	public void setEvent(boolean event) {
		this.event = event;
	}


	public boolean isDiscount() {
		return discount;
	}


	public void setDiscount(boolean discount) {
		this.discount = discount;
	}


	public String getOfferName() {
		return offerName;
	}


	public void setOfferName(String offerName) {
		this.offerName = offerName;
	}


	public String getOfferDescription() {
		return offerDescription;
	}


	public void setOfferDescription(String offerDescription) {
		this.offerDescription = offerDescription;
	}


	public UploadedFile getPicture() {
		return picture;
	}


	public void setPicture(UploadedFile picture) {
		this.picture = picture;
	}


	public Date getEndDate() {
		return endDate;
	}


	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}


	public double getInitialPrice() {
		return initialPrice;
	}


	public void setInitialPrice(double initialPrice) {
		this.initialPrice = initialPrice;
	}

	public String getEventPlace() {
		return eventPlace;
	}

	public void setEventPlace(String eventPlace) {
		this.eventPlace = eventPlace;
	}

	public Date getEventStartDate() {
		return eventStartDate;
	}

	public void setEventStartDate(Date eventStartDate) {
		this.eventStartDate = eventStartDate;
	}

	public Time getEventStartTime() {
		return eventStartTime;
	}

	public void setEventStartTime(Time eventStartTime) {
		this.eventStartTime = eventStartTime;
	}

	public Time getEventEndTime() {
		return eventEndTime;
	}

	public void setEventEndTime(Time eventEndTime) {
		this.eventEndTime = eventEndTime;
	}

	public String getStrEventStartTime() {
		return strEventStartTime;
	}

	public void setStrEventStartTime(String strEventStartTime) {
		this.strEventStartTime = strEventStartTime;
	}

	public String getStrEventEndTime() {
		return strEventEndTime;
	}

	public void setStrEventEndTime(String strEventEndTime) {
		this.strEventEndTime = strEventEndTime;
	}

	public Date getDiscountEndDate() {
		return discountEndDate;
	}

	public void setDiscountEndDate(Date discountEndDate) {
		this.discountEndDate = discountEndDate;
	}

	public double getDiscountPrice() {
		return discountPrice;
	}

	public void setDiscountPrice(double discountPrice) {
		this.discountPrice = discountPrice;
	}

	public int getInitialAmount() {
		return initialAmount;
	}

	public void setInitialAmount(int initialAmount) {
		this.initialAmount = initialAmount;
	}

	public ArrayList<Subcategory> getSubcategories() {
		return subcategories;
	}

	public void setSubcategories(ArrayList<Subcategory> subcategories) {
		this.subcategories = subcategories;
	}

	public int getSelectedSubcategoryPK() {
		return selectedSubcategoryPK;
	}

	public void setSelectedSubcategoryPK(int selectedSubcategoryPK) {
		this.selectedSubcategoryPK = selectedSubcategoryPK;
	}

	public boolean isRenderDiscount() {
		return renderDiscount;
	}

	public void setRenderDiscount(boolean renderDiscount) {
		this.renderDiscount = renderDiscount;
	}

	public boolean isRenderEvent() {
		return renderEvent;
	}

	public void setRenderEvent(boolean renderEvent) {
		this.renderEvent = renderEvent;
	}

	public ArrayList<MyOfferDisplay> getMyOfferDisplay() {
		return myOfferDisplay;
	}

	public void setMyOfferDisplay(ArrayList<MyOfferDisplay> myOfferDisplay) {
		this.myOfferDisplay = myOfferDisplay;
	}

	public int getSelectedOfferId() {
		return selectedOfferId;
	}

	public void setSelectedOfferId(int selectedOfferId) {
		this.selectedOfferId = selectedOfferId;
	}

	public int getThisOfferId() {
		return thisOfferId;
	}

	public void setThisOfferId(int thisOfferId) {
		this.thisOfferId = thisOfferId;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public int getAmountLeft() {
		return amountLeft;
	}

	public void setAmountLeft(int amountLeft) {
		this.amountLeft = amountLeft;
	}

	public boolean isValid() {
		return valid;
	}

	public void setValid(boolean valid) {
		this.valid = valid;
	}

	public ArrayList<ReservatedOffer> getResOffers() {
		return resOffers;
	}

	public void setResOffers(ArrayList<ReservatedOffer> resOffers) {
		this.resOffers = resOffers;
	}

	public String getResType() {
		return resType;
	}

	public void setResType(String resType) {
		this.resType = resType;
	}

	
	
	

}
